package com.dingpeikeji.quickdeer.mobile.service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dingpeikeji.quickdeer.core.common.service.CrudService;
import com.dingpeikeji.quickdeer.core.modules.orders.dao.TOrdersDao;
import com.dingpeikeji.quickdeer.core.modules.trip.entity.MealsInfo;
import com.dingpeikeji.quickdeer.mobile.dao.TripCounselorDao;
import com.dingpeikeji.quickdeer.mobile.entity.TripCounselorInfo;

@Service
@Transactional(readOnly = true)
public class TripCounselorService extends CrudService<TripCounselorDao, TripCounselorInfo>{
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private TripCounselorDao tripCounselorDao; 
	@Autowired
	private TOrdersDao tOrdersDao;
	
	/**
	 * 获取用户的行程记录
	 */
	public List<TripCounselorInfo> getTripCounselorList(String userId) {
		return tripCounselorDao.getTripCounselorList(userId);
	}
	
	/**
	 * 插入用户行程记录
	 * @param info
	 * @return
	 */
	public Integer insertTrip(TripCounselorInfo info){
		return tripCounselorDao.insertTrip(info);
	}
	
	/**
	 * 插入行程规划
	 * @param info
	 * @return
	 */
	public Integer insertPreview(TripCounselorInfo info){
		info.setTripPreviewId(UUID.randomUUID().toString().replace("-", "").toUpperCase());
		info.setPreviewCreateTime(new Date());
		info.setIsDisable("0");
		return tripCounselorDao.insertPreview(info);
	}
	/**
	 * 修改行程规划
	 * @param info
	 * @return
	 */
	public Integer updateTripPreview(TripCounselorInfo info){
		return tripCounselorDao.updateTripPreview(info);
	}
	/**
	 * 根据tripid获取行程规划
	 * @param info
	 * @return
	 */
	public List<TripCounselorInfo> getTripPreviewList(String tripCounselorId){
		return tripCounselorDao.getTripPreviewList(tripCounselorId);
	}
	
	/**
	 * 根据id查找行程规划单天内容
	 * @param tripPreviewId
	 * @return
	 */
	public TripCounselorInfo getPreviewById (String tripPreviewId){
		return tripCounselorDao.getPreviewById(tripPreviewId);
	}
	
	/**
	 * 根据Id删除行程规划
	 * @param tripPreviewId
	 * @return
	 */
	public Integer deleteById(String tripPreviewId){
		return tripCounselorDao.deleteById(tripPreviewId);
	}
	
	/**
	 * 设置前端可见
	 * @param tripCounselorId
	 * @return
	 */
	public Integer setShow(String tripCounselorId){
		return tripCounselorDao.setShow(tripCounselorId);
	}
	
	/**
	 * 设置前端不可见
	 * @param tripCounselorId
	 * @return
	 */
	public Integer setDisable(String tripCounselorId){
		return tripCounselorDao.setDisable(tripCounselorId);
	}
	
	/**
	 * 设置套餐价格
	 * @param base
	 * @return
	 */
	public Integer updateMeals(MealsInfo info){
		return tripCounselorDao.updateMeals(info);
	}
	
	
	/**
	 * 获取套餐
	 * @param base
	 * @return
	 */
	public MealsInfo getMeals(){
		return tripCounselorDao.getMeals();
	}
	
	
	/**
	 * 根据orderid获取行程顾问信息
	 * @param orderId
	 * @return
	 */
	public TripCounselorInfo getTripByOrderId(String orderId){
		return tripCounselorDao.getTripByOrderId(orderId);
	}
	
	public Integer updateTripState(String orderId,String payState){
		return tripCounselorDao.updateTripState(orderId, payState);
	}
}
